#include "PlayerStats.h"

PlayerStats::PlayerStats() {
	_hitPoints = _maxHitPoints = 1;
	_manaPoints = _maxManaPoints = 1;
	_damage = 1;
	_bonusDamage = 0;
}

PlayerStats::PlayerStats(const PlayerStats*& stats) {
	_hitPoints = stats->_hitPoints;
	_maxHitPoints = stats->_maxHitPoints;
	_manaPoints = stats->_manaPoints;
	_maxManaPoints = stats->_maxManaPoints;
	_damage = stats->_damage;
	_bonusDamage = stats->_bonusDamage;
}

PlayerStats::~PlayerStats(void) {}

void PlayerStats::setHitPoints(int hp) {
	if(hp >= _maxHitPoints)
		_hitPoints = _maxHitPoints;
	else if(hp <= 0) 
		_hitPoints = 0;
	else
		_hitPoints = hp;
}

void PlayerStats::setMaxHitPoints(int maxHP) {
	if(maxHP <= _hitPoints && maxHP >= 0) {
		_maxHitPoints = maxHP;
		this->setHitPoints(maxHP);
	} else if (maxHP<0) {
		_maxHitPoints = 0;
		this->setHitPoints(0);
	} else
		_maxHitPoints = maxHP;
}

void PlayerStats::setManaPoints(int mp) {
	if(mp >= _maxManaPoints)
		_manaPoints = _maxManaPoints;
	else if(mp <= 0) 
		_manaPoints = 0;
	else
		_manaPoints = mp;
}

void PlayerStats::setMaxManaPoints(int maxMP) {
	if(maxMP <= _manaPoints && maxMP >= 0) {
		_maxManaPoints = maxMP;
		this->setManaPoints(maxMP);
	} else if (maxMP<0) {
		_maxManaPoints = 0;
		this->setManaPoints(0);
	} else
		_maxManaPoints = maxMP;
}

void PlayerStats::setDamage(int dmg) {
	if(dmg <= 0)
		_damage = 0;
	else
		_damage = dmg;
}

void PlayerStats::setBonusDamage(int bonusDMG) {
	if(bonusDMG <= 0)
		_bonusDamage = 0;
	else 
		_bonusDamage = bonusDMG;
}

int PlayerStats::getHitPoints() {
	return _hitPoints;
}

int PlayerStats::getMaxHitPoints() {
	return _maxHitPoints;
}

int PlayerStats::getManaPoints() {
	return _manaPoints;
}

int PlayerStats::getMaxManaPoints() {
	return _maxManaPoints;
}

int PlayerStats::getDamage() {
	return _damage;
}

int PlayerStats::getBonusDamage() {
	return _bonusDamage;
}

void PlayerStats::setStats(int maxHP, int maxMP, int dmg) {
	this->setMaxHitPoints(maxHP);
	this->setHitPoints(maxHP);
	this->setMaxManaPoints(maxMP);
	this->setManaPoints(maxMP);
	this->setDamage(dmg);
}
